home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-05 / drivers1.zip / 3C507.ASM < prev    next >
Assembly Source File  |  1992-01-23  |  6KB  |  245 lines

  1. version    equ    0
  2.  
  3.     include    defs.asm
  4.  
  5. ;Ported from Tim Krauskopf's micnet.asm, an assembly language
  6. ;driver for the MICOM-Interlan NI5210 by Russell Nelson.  Any bugs
  7. ;are due to Russell Nelson.
  8.  
  9. ;  Copyright, 1988-1992, Russell Nelson, Crynwr Software
  10.  
  11. ;   This program is free software; you can redistribute it and/or modify
  12. ;   it under the terms of the GNU General Public License as published by
  13. ;   the Free Software Foundation, version 1.
  14. ;
  15. ;   This program is distributed in the hope that it will be useful,
  16. ;   but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. ;   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  18. ;   GNU General Public License for more details.
  19. ;
  20. ;   You should have received a copy of the GNU General Public License
  21. ;   along with this program; if not, write to the Free Software
  22. ;   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  23.  
  24.     .286                ;the 3c507 requires a 286.
  25.  
  26. code    segment    word public
  27.     assume    cs:code, ds:code
  28.  
  29. ;
  30. ;  Equates for controlling the 3c507 board
  31. ;
  32. IO_CONTROL    equ    06h
  33. IO_INTCLR    equ    0ah
  34. IO_CA        equ    0bh
  35. IO_RAM        equ    0eh
  36. IO_INT        equ    0fh
  37.  
  38. ;IO_CONTROL bits:
  39. _RST    equ    80h            ;not reset
  40. LBK    equ    20h            ;loopback
  41. IEN    equ    04h            ;interrupt enable
  42. VB0    equ    01h            ;vb0.
  43.  
  44.     public    int_no
  45. int_no        db    3,0,0,0        ; interrupt number
  46. io_addr        dw    300h,0        ; I/O address for card
  47. base_addr    dw      0c000h,0    ; base segment for board
  48.  
  49.     public    driver_class, driver_type, driver_name, driver_function, parameter_list
  50. driver_class    db    BLUEBOOK, IEEE8023, 0        ;from the packet spec
  51. driver_type    db    13        ;from the packet spec
  52. driver_name    db    "3c507",0    ;name of the driver.
  53. driver_function    db    2
  54. parameter_list    label    byte
  55.     db    1    ;major rev of packet driver
  56.     db    9    ;minor rev of packet driver
  57.     db    14    ;length of parameter list
  58.     db    EADDR_LEN    ;length of MAC-layer address
  59.     dw    GIANT    ;MTU, including MAC headers
  60.     dw    MAX_MULTICAST * EADDR_LEN    ;buffer size of multicast addrs
  61.     dw    0    ;(# of back-to-back MTU rcvs) - 1
  62.     dw    0    ;(# of successive xmits) - 1
  63. int_num    dw    0    ;Interrupt # to hook for post-EOI
  64.             ;processing, 0 == none,
  65.  
  66. enable_network:
  67. ;  connect to network
  68.     loadport
  69.     setport    IO_CONTROL
  70.     mov    al,_RST or IEN or VB0
  71.     out    dx,al
  72.     ret
  73.  
  74.  
  75. reset_586:
  76. ;  Reset the chip
  77.     loadport
  78.     setport    IO_CONTROL
  79.     mov    al,LBK
  80.     out    dx,al
  81.     jmp    $+2
  82.     jmp    $+2
  83.     mov    al,_RST or LBK or VB0
  84.     out    dx,al
  85.     setport    IO_INTCLR        ;clear the interupt latch.
  86.     out    dx,al
  87.     ret
  88.  
  89.  
  90.     public    get_address
  91. get_address:
  92. ;get the address of the interface.
  93. ;enter with es:di -> place to get the address, cx = size of address buffer.
  94. ;exit with nc, cx = actual size of address, or cy if buffer not big enough.
  95.     assume    ds:code
  96.     cmp    cx,EADDR_LEN        ;make sure that we have enough room.
  97.     jb    get_address_2
  98.     mov    cx,EADDR_LEN
  99.     mov    dx,io_addr        ; Get our IO base address.
  100.     cld
  101. get_address_1:
  102.     in    al,dx            ; get a byte of the eprom address
  103.     stosb                ; put it away
  104.     inc    dx            ; next register
  105.     loop    get_address_1        ; go back for rest
  106.     mov    cx,EADDR_LEN
  107.     clc
  108.     ret
  109. get_address_2:
  110.     stc
  111.     ret
  112.  
  113.  
  114. doca:
  115. ;we may be called from places in which ds is unknown.
  116.     assume    ds:nothing
  117.     loadport
  118.     setport IO_CA
  119.     out    dx, al
  120.     ret
  121.     assume    ds:code
  122. ;yet, we really should assume ds==code for the rest of this stuff.
  123.  
  124.  
  125. ;
  126. ; Here we include the code that is common between 82586 implementations.
  127. ; Everything above this is resident.
  128.     include    82586.asm
  129. ; Everything below this is discarded upon installation.
  130.  
  131.     public    usage_msg
  132. usage_msg    db    "usage: 3c507 [-n] [-d] [-w] <packet_int_no> <int_no> <io_addr> <base_addr>",CR,LF,'$'
  133.  
  134.     public    copyright_msg
  135. copyright_msg    db    "Packet driver for the 3C507, version ",'0'+(majver / 10),'0'+(majver mod 10),".",'0'+version,".",'0'+i82586_version,CR,LF,'$'
  136.  
  137. big_window_only    label    byte
  138.     db    "Only 64K window implemented.",CR,LF,'$'
  139. main_memory_only    label    byte
  140.     db    "Memory window must be in the 0xc000 -> 0xd800 range.",CR,LF,'$'
  141.  
  142. check_board:
  143.     mov    SCP,0            ; 16 bit bus type in scb.
  144.  
  145.     call    write_id_pat
  146.  
  147.     loadport
  148.     setport    IO_RAM
  149.     in    al,dx
  150.     and    al,3            ;get the window size.
  151. ;00 = 16K, 01 = 32K, 10 = 48K, 11 = 64K.
  152.     cmp    al,3
  153.     je    check_board_2
  154.     mov    dx,offset big_window_only
  155.     stc
  156.     ret
  157. check_board_2:
  158.     in    al,dx
  159.     test    al,20h            ;8088 address or 80286 address?
  160.     je    check_board_3
  161.     mov    dx,offset main_memory_only
  162.     stc
  163.     ret
  164. check_board_3:
  165.     and    al,18h
  166. ;00 = 0c000h, 08 = 0c800h, 10 = 0d000h, 18 = 0d800h.
  167.     mov    ah,al
  168.     xor    al,al
  169.     add    ah,0c0h
  170.     mov    base_addr,ax
  171.  
  172.     setport    IO_INT
  173.     in    al,dx
  174.     and    al,0fh
  175.     mov    int_no,al
  176.  
  177.     setport    IO_CONTROL
  178.     mov    al,_RST or IEN or VB0
  179.     out    dx,al
  180.  
  181.     ret
  182.  
  183.  
  184. write_id_pat:
  185.     mov    dx,100h
  186.     xor    al,al
  187.     out    dx,al            ;reset hardware pattern generator
  188.     mov    cx,0ffh
  189.     mov    al,0ffh
  190. write_id_pat_1:
  191.     out    dx,al            ;keep writing matching values...
  192.     shl    al,1
  193.     jnc    write_id_pat_2
  194.     xor    al,0e7h
  195. write_id_pat_2:
  196.     loop    write_id_pat_1
  197.     xor    al,al
  198.     out    dx,al            ;now put adapter in RUN state.
  199.     ret
  200.  
  201.  
  202.     public    parse_args
  203. parse_args:
  204.     mov    di,offset int_no
  205.     call    get_number
  206.     mov    di,offset io_addr
  207.     call    get_number
  208.     mov    di,offset base_addr
  209.     call    get_number
  210.     clc
  211.     ret
  212.  
  213.  
  214. int_no_name    db    "Interrupt number ",'$'
  215. io_addr_name    db    "I/O port ",'$'
  216. base_addr_name    db    "Memory address ",'$'
  217.  
  218.  
  219.     public    print_parameters
  220. print_parameters:
  221.     mov    di,offset int_no
  222.     mov    dx,offset int_no_name
  223.     call    print_number
  224.     mov    di,offset io_addr
  225.     mov    dx,offset io_addr_name
  226.     call    print_number
  227.     mov    ax,memory_begin
  228.     mov    cl,4
  229.     shr    ax,cl
  230.     add    base_addr,ax
  231.     push    ax
  232.     mov    di,offset base_addr
  233.     mov    dx,offset base_addr_name
  234.     call    print_number
  235.     pop    ax
  236.     sub    base_addr,ax
  237.     ret
  238.  
  239.     include    memtest.asm
  240.  
  241. code    ends
  242.  
  243.     end
  244.  
  245.